package com.jz.community.moduleshoppingguide.home.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.moduleshoppingguide.R;
import com.jz.community.moduleshoppingguide.home.bean.ChunnelTypeBean;

import java.util.List;

public class OutGoodsTypeAdapter extends BaseQuickAdapter<ChunnelTypeBean, BaseViewHolder> {

    public OutGoodsTypeAdapter(int layoutResId, @Nullable List<ChunnelTypeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ChunnelTypeBean entity) {
        boolean isSelect = entity.isSelect();

        TextView tv = helper.getView(R.id.item_out_type_tv);
        tv.setText(entity.getName());

        if (isSelect) {
            tv.setTextColor(mContext.getResources().getColor(R.color.home_red));
        } else {
            tv.setTextColor(mContext.getResources().getColor(R.color.font_black));
        }
    }

    public void change(int oldPosition, int position) {
        mData.get(oldPosition).setSelect(false);
        mData.get(position).setSelect(true);
        notifyDataSetChanged();
    }
}
